require("./index1.css");
// 引入swiper
// let Swiper = require("../../libs/swiper/swiper-bundle.js");
// require("../../libs/swiper/swiper-bundle.css");
// // 引入tapbar的less
// require("../../assets/css/zjf-dom.less");
// 引入tapBar的js;
let footer = require("../../assets/js/zjf-dom.js");
const axios = require("axios");
window.addEventListener("load", function () {
	footer.nav("index1");
	function $(v) {
		return document.querySelector(v);
	}
	axios.defaults.baseURL = "http://fitness.h5.itsource.cn:3701";
	let token = localStorage.getItem("token");
	axios.defaults.headers.common["Authorization"] = "Bearer " + token;
	//打卡时间
	function clock() {
		axios.get("/api/user/clockInInfo").then((v) => {
			let clock = v.data.data.clockCount;
			console.log(v);
			$("#clockin").textContent = clock;

			//打卡后改变打卡按钮
			if (!v.data.data.isClockIn) {
				alert("打卡失败");
			} else {
				$("#clockbtn").disabled = "ture";
				$("#clockbtn").style.color = "#999";
				$("#clockbtn").style.border = "#999";
				$("#clockbtn").textContent = "已打卡";
			}
		});
	}
	clock();
	$("#clockbtn").addEventListener("click", function () {
		// 发送打卡信息
		axios.post("/api/user/clockIn").then((v) => {
			if (v.data.errnp === 0) {
				alert(v.data.message);
				clock();
			}
		});
	});
	axios.get("/api/user/info").then((v) => {
		$("#rank").textContent = v.data.data.ranking;
		$("#badges").textContent = v.data.data.badges;
	});

	// swiper

	// var mySwiper = new Swiper(".swiper", {
	// 	direction: "vertical", // 垂直切换选项
	// 	loop: true, // 循环模式选项

	// 	// 如果需要分页器
	// 	pagination: {
	// 		el: ".swiper-pagination",
	// 	},
	// });
});
